package com.onec.service.netty.byteBuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;

public class HeapByteBuf {


  public static void main(String[] args) {

    ByteBuf byteBuf = ByteBufAllocator.DEFAULT.heapBuffer();
    byteBuf.writeBytes("我是草香欣二".getBytes());
    if (byteBuf.hasArray()) {

      byte[] bytes = byteBuf.array();

      int officset = byteBuf.arrayOffset() + byteBuf.readerIndex();
      System.out.println("--" + officset);

      int length = byteBuf.readableBytes();
      System.out.println(length);

    }

    byteBuf.release();
  }
}
